package com.chezai.client.adapter;

import android.support.annotation.LayoutRes;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chezai.client.R;
import com.chezai.client.bean.TerminalParameter;

/**
 * 配置参数Adapter
 * Created by likunyang on 2017/9/12.
 */

public class DeployAdapter extends BaseQuickAdapter<TerminalParameter, BaseViewHolder> {
    public DeployAdapter(@LayoutRes int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder holder, TerminalParameter item) {
        holder.setText(R.id.tv_params_des, item.getDescription());
        long id = item.getId();
        if (id == 128) {
            String mile = item.getValue();
            holder.setText(R.id.tv_params_value, String.format("%.2f", Float.valueOf(mile) / 100) + "");
        } else if (id == 1048578) {
            holder.setText(R.id.tv_params_value, "0".equals(item.getValue()) ? "不自动请求上传" : "自动请求上传");
        } else if (id == 1048579) {
            holder.setText(R.id.tv_params_value, "1".equals(item.getValue()) ? "自动报读" : "不报读");
        } else if (id == 1048581) {
            holder.setText(R.id.tv_params_value, "0".equals(item.getValue()) ? "不上传" : item.getValue());
        } else if (id == 1048584) {
            holder.setText(R.id.tv_params_value, "1".equals(item.getValue()) ? "允许" : "禁止");
        } else if (id == 1048585) {
            holder.setText(R.id.tv_params_value, "1".equals(item.getValue()) ? "允许" : "禁止");
        } else {
            holder.setText(R.id.tv_params_value, item.getValue() + "");
        }
    }
}
